export function collectParamsList(data, paramsList) {
  const paramsHeaderItem = {
    name: '',
    type: 'headers',
    value: ''
  }
  const paramsBodyItem = {
    name: '',
    type: 'body',
    value: ''
  }
  const headers = JSON.parse(data.headers)
  if (headers.length > 0) {
    for (const i in headers) {
      console.log('i:', i)
      paramsHeaderItem.name = headers[i].name
      paramsHeaderItem.value = headers[i].value
      paramsList.push(paramsHeaderItem)
    }
  }
  const body = JSON.parse(data.params)
  if (body.length > 0) {
    for (const j in body) {
      paramsBodyItem.name = body[j].name
      paramsBodyItem.value = body[j].value
      paramsList.push(paramsBodyItem)
    }
  }
}

export function collectList(data, targetList, type) {
  if (data) {
    const typeObj = {
      headers: 'headers',
      params: 'body',
      response_headers: 'headers',
      response_params: 'body'
    }
    const temp = JSON.parse(data)
    if (temp.length > 0) {
      temp.forEach(item => {
        item.type = typeObj[type]
        targetList.push(item)
      })
    }
  }
}
